package com.aifast.system.sys.dao;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.aifast.system.sys.entity.SysTenant;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/**
 * 租户Mapper接口
 *
 * @author fujian
 * @date 2022-10-30
 */
@Mapper
public interface SysTenantDao extends BaseMapper<SysTenant> {

    default LambdaQueryWrapper<SysTenant> select(String name, Integer state, String domain) {
        return new LambdaQueryWrapper<SysTenant>()
                .eq(ObjectUtil.isNotNull(state), SysTenant::getState, state)
                .like(StrUtil.isNotBlank(name), SysTenant::getName, name).or()
                .like(StrUtil.isNotBlank(name), SysTenant::getDomain, name).or()
                .like(StrUtil.isNotBlank(name), SysTenant::getContact, name)
                .orderByDesc(SysTenant::getId);
    }

}
